package com.eiletxie.springcloud.webfluxtest;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.function.Function;

public class GHImpl implements  GH {
    @Override
    public <T> Mono<T> run(Mono<T> toRun, Function<Throwable, Mono<T>> fallback) {
        return null;
    }

    @Override
    public <T> Flux<T> run(Flux<T> toRun, Function<Throwable, Flux<T>> fallback) {
        return null;
    }
   /* @Override
    public <T> Mono<T> run(Mono<T> toRun, Function<Throwable, Mono<T>> fallback) {
        return Mono.;
    }

    @Override
    public <T> Flux<T> run(Flux<T> toRun, Function<Throwable, Flux<T>> fallback) {
        return null;
    }



    @Override
    public <T> Mono<T> run(Mono<T> toRun, Function<Throwable, Mono<T>> fallback) {
        HystrixObservableCommand<T> command = createCommand(toRun, fallback);

        return Mono.create(s -> {
            Subscription sub = command.toObservable().subscribe(s::success, s::error,
                    s::success);
            s.onCancel(sub::unsubscribe);
        });
    }

    @Override
    public <T> Flux<T> run(Flux<T> toRun, Function<Throwable, Flux<T>> fallback) {
        HystrixObservableCommand<T> command = createCommand(toRun, fallback);

        return Flux.create(s -> {
            Subscription sub = command.toObservable().subscribe(s::next, s::error,
                    s::complete);
            s.onCancel(sub::unsubscribe);
        });
    }*/


}
